﻿Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.ComponentModel
Imports NHibernate
Imports SIAVU.Dominio

Namespace Persistencia

    Public Class CiudadPersistencia

        Public Sub getById(ByRef oCiudad As Ciudad)
            Dim session As ISession = Nothing
            Try
                session = NHibernateHelper.OpenSession
                oCiudad = DirectCast(session.Get(GetType(Ciudad), oCiudad.CiudadID), Ciudad)


            Catch ex As Exception
                Throw
            Finally
                session.Close()
            End Try

        End Sub

        Public Sub guardar(ByVal oCiudad As Ciudad)
            Dim session As ISession = NHibernateHelper.OpenSession()
            Dim oTransaccion As ITransaction = Nothing
            Try
                oTransaccion = session.BeginTransaction()
                oTransaccion.Begin()

                session.SaveOrUpdate(oCiudad)
                oTransaccion.Commit()

            Catch ex As Exception
                oTransaccion.Rollback()
                Throw

            Finally
                session.Close()
            End Try
        End Sub

    End Class

End Namespace

